﻿using System;
using System.Collections.Generic;
using TeamTasker.Server.BusinessLogic.Format.Support;


namespace TeamTasker.Server.BusinessLogic.Format
{
    public enum PropertyType
    {
        Int, 
        Float, 
        String, 
        Date, 
        Time, 
        DateTime,
        Enum
    }

    public class PropertyFormatter
    {
        private static IDictionary<PropertyType, ITypeFormatter> formatters;

        static PropertyFormatter()
        {
            formatters = new Dictionary<PropertyType, ITypeFormatter>();
            formatters.Add(PropertyType.Int, new IntegerFormatter());
            formatters.Add(PropertyType.Float, new FloatFormatter());
            formatters.Add(PropertyType.String, new StringFormatter());
            formatters.Add(PropertyType.Date, new DateFormatter());
            formatters.Add(PropertyType.Time, new TimeFormatter());
            formatters.Add(PropertyType.DateTime, new DatetimeFormatter());
            formatters.Add(PropertyType.Enum, new EnumFormatter());
        }
    
        public string ValueToString(object value, PropertyType type)
        {
            ITypeFormatter formatter = formatters[type];
            return formatter.ValueToString(value);
        }
    }
}
